<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>login</title>
	<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
	<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">

	<!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
	<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
	
	<style type="text/css">
	html{height: 100%}
	body{background:#16a085;font-family: '\5FAE\8F6F\96C5\9ED1';height:100%;overflow: hidden}
input:-webkit-autofill {-webkit-box-shadow: 0 0 0px 100px white inset;}
		.login_box{width:320px;height:500px;position: fixed;top:50%;left:50%;margin-top: -250px;margin-left: -160px;overflow:hidden;padding:0 40px;box-shadow:0 -15px 30px #0d957a;border-radius:5px;box-sizing: content-box;}
		.login_box button{width:100%;height:40px;line-height: 40px;border:none;outline: none;color:#fff;font-size: 1.2em;background-image: linear-gradient(to bottom,#337ab7 0,#286090 100%);}
		.login_box button:hover{background-image: linear-gradient(to bottom,#3070b0 0,#206090 100%);}
		.login_item{width:100%;height:40px;background: #777;margin-bottom: 30px;background: white;overflow: hidden;position: relative;}
		.login_item img{position: absolute;right:0;height:40px;width:150px;cursor: pointer;}
		.login_item input{float:right;width:265px;height:40px;margin-right:5px;border:none;outline: none;font-size: 1.5em}
		.login_item label{width:40px;height:40px;background:#286090;float: left;line-height: 40px;text-align: center;color:#fff;top:0;}
		.login_title{color:#fff;font-size: 1.8em;line-height: 80px}
		.login_welcome{color:#fff;font-size: 1em;line-height: 40px;font-weight: normal;}
		.login_error{color:red;font-size: 1em;line-height: 40px}
		canvas{z-index:-1;position:absolute;}
		#captcha{width:115px;margin-right: 150px}
	</style>
</head>
<body>
	<canvas class="J_codeimg" id="myCanvas" onclick="createCode()">对不起，您的浏览器不支持canvas，请下载最新版浏览器!</canvas>
	<div class="login_box">
		<h2 class="login_title">管理员登陆</h2>
		<div class="login_item">
			<label class="glyphicon glyphicon-user" for="username"></label>
			<input type="text" id="username" name="username"  placeholder="邮箱...">
		</div>
		<div class="login_item">
			<label class="glyphicon glyphicon-lock" for="password"></label>
			<input type="password" id="password" name="password"  placeholder="密码...">
		</div>
		<div class="login_item">
		
			<label class="glyphicon glyphicon-text-background" for="captcha"></label>
			<input type="text" id="captcha" name="captcha">
			<img id="captcha_img" src="<?php echo site_url('admin/login/captcha');?>" title="刷新验证码"  onclick="fresh_captcha();"/>
		</div>
		<button id="send">登     陆</button>
		<h2 class="login_welcome">欢迎登陆<?php echo $admin_title;?></h2>
		<h2 class="login_welcome" style="text-align: right;margin-top:-10px">——<?php echo $company_name;?></h2>
		<h2 class="login_error" style="margin-top: -10px"></h2>
	</div>
</body>
<script type="text/javascript" src="/static/admin/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/static/admin/js/particleground.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script type="text/javascript">
$(function(){
	$('body').particleground({
		dotColor: '#5cbdaa',
		lineColor: '#5cbdaa'
	});

    $('#send').click(function(){
    	var btn = $(this);
    	var btn_val = btn.text();
    	btn.attr('disabled',true).text('正在登陆...');
        $.ajax({
             type: "POST",
             url: "<?php echo site_url('admin/login/ajax_login');?>",
             dataType: "json",
             data:{username:$('#username').val(),password:$('#password').val(),captcha:$('#captcha').val()},
             success:function(data){
             	btn.attr('disabled',false).text(btn_val);
             	if(data.statu == 'ok'){
             		window.location.href = '<?php echo $redirect;?>';
             	}else{
             		fresh_captcha();
             		$('.login_error').text(data.message);
             	}
             }
        });
    });
});
function fresh_captcha(){
	$('#captcha_img').attr("src","<?php echo site_url('admin/login/captcha');?>?"+Math.random());
}

</script>
</html>